package com.ruoyi.qualityControl.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.qualityControl.domain.QcFalseSignComplain;
import com.ruoyi.qualityControl.domain.vo.QcFalseSignComplainEnum;
import com.ruoyi.qualityControl.domain.vo.QcFalseSignComplainVo;
import com.ruoyi.common.domain.vo.TableVo;
import com.ruoyi.qualityControl.mapper.QcFalseSignComplainMapper;
import com.ruoyi.qualityControl.service.QcFalseSignComplainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class QcFalseSignComplainServiceImpl implements QcFalseSignComplainService {
    @Autowired
    private QcFalseSignComplainMapper qcFalseSignComplainMapper;

    @Override
    public List<QcFalseSignComplain> settleAll() {
        return qcFalseSignComplainMapper.selectAll();
    }

    @Override
    public Boolean insert(QcFalseSignComplain qcFalseSignComplain) {
        return qcFalseSignComplainMapper.insert(qcFalseSignComplain);
    }

    @Override
    public Boolean update(QcFalseSignComplain qcFalseSignComplain) {
        return qcFalseSignComplainMapper.update(qcFalseSignComplain);
    }

    @Override
    public Boolean deleteById(Integer id) {
        return qcFalseSignComplainMapper.deleteById(id);
    }

    @Override
    public List<QcFalseSignComplain> search(QcFalseSignComplainVo vo) {
        PageHelper.startPage(vo.getPageDate());
        return qcFalseSignComplainMapper.search(vo);
    }

    @Override
    public List<TableVo> initTable() {
        List<TableVo> list = new ArrayList<>();
        TableVo tableVo = new TableVo();
        String[] fields = {"transportCode","workOrderCode","networkName","contractAreaName","complainSource","complainReason"
                ,"deliveryAddress","markType","isAppoint","appointSuccessType","forecastExamineAmount","isMessageNotification"
                , "messageSentType","expressmanId","signType","signer","isNightSign","replaceSiteType","isExplain","noExplain"
                ,"explainStatus","explainType","signTime","complainTime","explainTime","negotiateTime"};
        for (String field : fields) {
            tableVo = new TableVo();
            tableVo.setFields(field);
            list.add(tableVo);
        }
        for (TableVo vo : list) {
            vo.setTranslate(QcFalseSignComplainEnum.getValue(vo.getFields()));
        }
        return list;
    }
}
